package parsing;

import java.io.*;

public class terminals{
	public static void main(String[] args){
		try{
			String[] terminals=new String[100];
			int count=0;
			String str;
			BufferedReader in = new BufferedReader(new FileReader("C:\\Users\\ChengXin\\Desktop\\terminal rules.txt"));
			
			while((str=in.readLine())!=null){
				String array[] = str.split(" ");
				terminals[count++]=array[0];
			}
			terminals[count++]="$";
            FileOutputStream out=new FileOutputStream("C:\\Users\\ChengXin\\Desktop\\terminals.txt");   
            BufferedWriter bufferedwriter = new BufferedWriter(new OutputStreamWriter(out));
			
			bufferedwriter.write(count+"\r\n");
			for(int i=0; i<count; i++)
				bufferedwriter.write(terminals[i]+" ");
			bufferedwriter.flush();
		}
		catch(Exception e){
			System.out.print(e.toString());
		}
	}
}